
// import set from '@feidao/web/atom/browser/local/set';
import remove from '@dfeidao/atom-web/local/remove';
import fire from '@dfeidao/atom-web/msg/fire';

import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import set from '@dfeidao/atom-web/local/set';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import error from '@dfeidao/atom-web/msgbox/error';
import success from '@dfeidao/atom-web/msgbox/success';
// import whoami from '@dfeidao/atom-web/msg/whoami';
// import { send_msg as url } from './config';
interface Aa {
	role_no: string;
}
export default async function a002(fd: IFeidaoAiBrowserComponent) {
	const obj = get(fd, 'obj') as Aa;

	const productid = get(fd, 'productid');
	if (!obj) {
		error('请选择要删除的角色');
		return;
	}
	const role_no = obj.role_no;

	const num = await nodejs('roler/zj-000001/s003', { productid, role_no });
	if (num === 1) {
		error('该角色已关联过角色权限或有用户分配了该角色');
		return;
	}

	const res = await nodejs('roler/zj-000001/s004', { productid, role_no });

	if (res === 'success') {
		success('删除成功');
		set(fd, 'page_no', 1);
		remove(fd, 'obj');
		fire('zj-000001', 'ec-001');
	} else {
		error('删除失败');
	}
}
